package cn.itcast.service.impl;

import cn.itcast.dao.CourierDao;
import cn.itcast.domain.Courier;
import cn.itcast.service.CourierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;



@Service
public class CourierServiceImpl implements CourierService {
    @Autowired
    private CourierDao courierDao;



    @Override
    public void save(Courier courier) {
        courierDao.save(courier);

    }

    @Override
    public Page<Courier> pageQuery(int page, int rows,Courier courier) {

       PageRequest pageList = PageRequest.of(page-1, rows);
        ExampleMatcher matcher = ExampleMatcher.matching()
                .withMatcher("courierNum" ,ExampleMatcher.GenericPropertyMatchers.contains())
                .withMatcher("company" ,ExampleMatcher.GenericPropertyMatchers.contains())
                .withMatcher("type" ,ExampleMatcher.GenericPropertyMatchers.contains());


        return  courierDao.findAll(Example.of(courier,matcher),pageList);
    }

    /**d
     * 还原
     * @param id
     */
    @Override
    public void updateDeltag(Integer id) {

   courierDao.updateDeltag(id);

    }

    @Override
    public void updateDeltag1(Integer ids) {
        courierDao.updateDeltag1(ids);
    }





}
